package pl.edu.mimuw.mas.editor.listener;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import pl.edu.mimuw.mas.editor.MainEditorWindow;
import pl.edu.mimuw.mas.utils.Marshaller;

/**
 * Implementacja Listenera dla przycisku "save" w menu
 * głównym aplikacji.
 */
public class SaveMenuItemListener implements SelectionListener {
	private final Logger log = LoggerFactory.getLogger(getClass());

	private final MainEditorWindow main;
	
	public SaveMenuItemListener(MainEditorWindow main) {
		this.main = main;
	}
	
	public void widgetSelected(SelectionEvent event) {
		log.debug("wybrano");
		save();
	}

	public void widgetDefaultSelected(SelectionEvent event) {
	}
	
	private void save() {
		Marshaller.save(main.getChart(), main.getFileName());	
	}
}
